<?php

Yii::import('zii.widgets.CPortlet');

class Category extends CPortlet
{

    protected function renderContent()
    {
        $categories = Categorydemo::model()->findAll(array('order' => 'lft'));
        $identifiers = array();
        foreach ($categories as $n => $category)
        {
            $identifiers[] = "'" . 'node_' . $category->id . "'";
        }
        $open_nodes = implode(',', $identifiers);

        $baseUrl = Yii::app()->baseUrl;

        $dataProvider = new CActiveDataProvider('Categorydemo');
        $this->render('Category/index', array(
            'dataProvider' => $dataProvider,
            'baseUrl' => $baseUrl,
            'open_nodes' => $open_nodes
        ));
    }
}